package com.rightsidetech.http.controller.admin.oss;

import com.aliyun.oss.OSS;
import com.rightsidetech.commom.base.ResponseData;
import com.rightsidetech.commom.config.AliyunOSSConfig;
import com.rightsidetech.commom.utils.UplodeUtils;
import com.rightsidetech.http.aspect.Auth;
import com.rightsidetech.http.aspect.Log;
import com.rightsidetech.http.aspect.Token;
import com.rightsidetech.http.base.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shenyu.client.springmvc.annotation.ShenyuSpringMvcClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;


/**
 * @Package: com.rightsidetech.http.controller.admin.system.maintain
 * @ClassName: OSSController
 * @Author: yinj
 * @CreateTime: 2021/6/1 11:16
 * @Description: 文件上传
 */
@RestController
@RequestMapping("/admin/file")
@ShenyuSpringMvcClient(path = "/admin/file/**")
@Api(tags = "文件上传")
public class AdminOSSController extends BaseController {

    @Autowired
    private OSS ossClient;

    @Autowired
    private AliyunOSSConfig aliyunOSSConfig;


    @Log
    @Token
    @PostMapping("/more_uplode")
    @ApiOperation("批量上传")
    @Auth(bizType = Auth.OPERATOR)
    public ResponseData<String[]> moreUplode(MultipartFile[] files) throws Exception {
        if (null == files || files.length == 0) {
            return ResponseData.fail("文件不能为空");
        }

        return UplodeUtils.adminMoreUplode(files,ossClient, aliyunOSSConfig);
    }



}
